package com.wxmp.wxapi.service.impl;

import com.wxmp.core.util.DateUtil;
import com.wxmp.wxapi.domain.WxpayOrder;
import com.wxmp.wxapi.service.UnionCardAccountService;
import com.wxmp.wxapi.vo.PayRecord;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author Johnkee
 */
//TODO:实际处理卡的逻辑
@Service
public class UnionCardAccountServiceImpl implements UnionCardAccountService {

    private Logger logger = LoggerFactory.getLogger(UnionCardAccountServiceImpl.class);


    @Override
    public float getUsableAmountByCardNo(String cardNo) {
        return 0.00f;
    }

    @Override
    public String getCardOwnerByCardNo(String cardNo) {
        return "李四";
    }

    /**
     * 处理微信通知充值成功的消息，卡处理成功返回1
     * @param payOrder
     * @return
     */
    @Override
    public int doNotify(WxpayOrder payOrder) {
        return 0;
    }

    @Override
    public List<PayRecord> getPayListByPage(PayRecord payRecord) {
        payRecord.setTotal(17);
        payRecord.setTotalPage(4);
        List<PayRecord> payRecordList = new ArrayList<>(17);
        for(int i=0;i<17;i++){
            PayRecord payRecordEntry = new PayRecord();
            payRecordEntry.setCardNo(payRecord.getCardNo());
            payRecordEntry.setOpenid(payRecord.getOpenid());
            payRecordEntry.setPayTime(DateUtil.getPastDate2(i));
            payRecordEntry.setPayStatus("消费成功");
            payRecordEntry.setGoodsName("饭菜");
            payRecordEntry.setAmount((i+1)+0.5f);
            payRecordList.add(payRecordEntry);
        }
        return payRecordList;
    }
}
